/*
 * GameObject.cpp
 *
 *  Created on: 30/07/2010
 *      Author: alex
 */

#include <cmath>
#include "core/utils.h"
#include "GameObject.h"

using std::string;
using utils::makeRect;


GameObject::GameObject(const string& _stopped) :
x(0), y(0), rect(makeRect(0, 0, 0, 0)), stopped(_stopped, &rect),
radius(stopped.getRect().w / 2), life(10) {
}


void GameObject::render(SDL_Surface *screen) {
	rect.x = x;
	rect.y = y;
	stopped.render(screen);
}


/*
 * Implementa a colisão por círculo.
 */
bool GameObject::collidesWith(const GameObject& other) const {
	int dist2 = pow(x - other.getX(), 2) + pow(y - other.getY(), 2);
	if (dist2 < pow(radius + other.radius, 2))
		return true;
	return false;
}
